package ecom.nopecom.admin;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.PageFactory;

import ecom.nopecom.BasePage;
import ecom.nopecom.account.Registration;
import ecom.nopecom.account.pagecontainer.LoginPageContainer;
import ecom.nopecom.util.Consumer;

public class AdminLogin extends BasePage {
	AdminLoginContainer pageContainer = PageFactory.initElements(nopeDriver, AdminLoginContainer.class);
	Registration registration = new Registration();
//	boolean LoggedInstatus = false;
	
	public void adminLogin(String adminusername,String adminpassword)
	{
		
		//login code
		pageContainer.username.sendKeys(adminusername);
		pageContainer.password.sendKeys(adminpassword);
		pageContainer.submit.click();
		
	}
	
	public void adminLoginAndReg(String adminfirstName, String adminlastName, String adminemail, String adminusername, String adminpassword)
	{
	
		adminLogin(adminusername, adminpassword);
		if(isAdminLoginFailed())
		registration.registerWithMandatoryFields(adminfirstName, adminlastName, adminemail, adminusername, adminpassword);
	}

	private boolean isAdminLoginFailed() {
		return true;//nopeDriver.isDisplayed("Admin Login Sucess");
	}

	public void login(Consumer consumer)
	{
		adminLogin(consumer.getUsername(),consumer.getPassword());
		consumer.setUserLoggedInStatus(true);
	}
	public void goToAdminLoginPage() {
		nopeDriver.navigate().to("http://demo.nopcommerce.com/login");
	}

	public String getAdminWelcomeMessage() {
	
		return "";
	}
	@Override
	public WebElement getLandingElement() {
		// TODO Auto-generated method stub
		return null;
	}

}
